function Cache() {
	ModuleBase.call(this);
	var a = this;
	this.error = "";
	this.key = "";
	this.dataKey = "";
	this.setKey = function(b) {
		this.key = b
	};
	this.getKey = function() {
		return this.key
	};
	this.setDataKey = function(b) {
		this.datakey = b
	};
	this.getDataKey = function() {
		return this.dataKey
	};
	this.getErrorInfo = function() {
		return this.error
	};
	this.unixTime = function() {
		return Math.round(Date.parse(new Date()) / 1000)
	};
	this.keyExists = function() {
		if (this.key == "") {
			this.error = L("please set the key value first, the key value can not be null");
			return false
		}
		if (typeof (gCache[this.key]) == "undefined") {
			this.error = L("the target is not in the cache list");
			return false
		}
		return true
	};
	this.readCache = function() {
		if (this.key == "") {
			this.error = L("please set the key value first, the key value can not be null");
			return false
		}
		if (typeof (gCache[this.key]) == "undefined") {
			this.error = L("the target is not in the cache list,so you can not get the page message from the cache list");
			return false
		}
		if (this.datakey == "") {
			this.datakey = "_"
		}
		if (typeof (gCache[this.key]["data"][this.datakey]) == "undefined") {
			this.error = L("the cache file is not exist");
			return false
		}
		var b = "";
		var c = "";
		b = gCache[this.key]["data"][this.datakey].body;
		c = gCache[this.key]["data"][this.datakey].cache_time;
		gCache[this.key]["data"][this.datakey].cache_time = this.unixTime();
		return {
			body : b,
			cache_time : c
		}
	};
	this.cleanCache = function() {
		if (this.key == "") {
			return true
		}
		if (typeof (gCache[this.key]) == "undefined") {
			return true
		}
		if (this.datakey == "") {
			this.datakey = "_"
		}
		if (typeof (gCache[this.key]["data"][this.datakey]) == "undefined") {
			return true
		}
		return delete gCache[this.key]["data"][this.datakey]
	};
	this.cleanCacheByKey = function() {
		if (this.key == "") {
			return true
		}
		if (typeof (gCache[this.key]) == "undefined") {
			return true
		}
		try {
			gCache[this.key]["data"] = {};
			return true
		} catch (b) {
			return false
		}
	};
	this.writeCache = function(d) {
		if (this.key == "") {
			this.error = L("please set the key value first, the key value can not be null");
			return false
		}
		if (typeof (gCache[this.key]) == "undefined") {
			this.error = L("the target is not in the cache list, not need cache");
			return false
		}
		if (this.datakey == "") {
			this.datakey = "_"
		}
		if (typeof (gCache[this.key]["data"][this.datakey]) == "undefined") {
			var c = 9999999999;
			var b = "";
			var e = 0;
			for (p in gCache[this.key]["data"]) {
				if (gCache[this.key]["data"][p].cache_time < c) {
					c = gCache[this.key]["data"][p].cache_time;
					b = p
				}
				e++
			}
			if (e >= gCache[this.key]["max"]) {
				if (false == delete gCache[this.key]["data"][b]) {
					this.error = L("the cache list is full,clear the overdue cache fail");
					return false
				}
			}
			gCache[this.key]["data"][this.datakey] = {
				body : d,
				cache_time : this.unixTime()
			}
		} else {
			gCache[this.key]["data"][this.datakey].body = d;
			gCache[this.key]["data"][this.datakey].cache_time = this.unixTime()
		}
		return (gCache[this.key]["data"][this.datakey].body == d)
	};
	this.getCount = function(b) {
		if (this.key == "") {
			this.error = L("please set the key value first, the key value can not be null");
			return false
		}
		var c = 0;
		for (p in gCache[this.key]["data"]) {
			c++
		}
		return c
	};
	this.getDefaultParams = function() {
		if (this.key == "") {
			this.error = L("please set the key value first, the key value can not be null");
			return false
		}
		if (typeof (gCache[this.key]) == "undefined") {
			this.error = L("the cache list is not exist");
			return false
		}
		if (typeof (gCache[this.key]["params"]) == "undefined") {
			this.error = L("the attribute of param is not exist");
			return false
		}
		return gCache[this.key]["params"]
	}
}
function CacheControl() {
	ModuleBase.call(this);
	var a = this;
	this.initCacheCtrl = function(c, f) {
		var e = c;
		if (false === e) {
			return false
		}
		var b = new Cache();
		b.setKey(e);
		var d = b.getDefaultParams();
		if (false !== d) {
			f.setParamsFormat(d)
		}
		var g = f.getFormatQs("q");
		b.setDataKey(g);
		return b
	};
	this.cleanCache = function(b) {
		if (typeof b.q === "undefined") {
			return false
		}
		if (typeof b.type === "undefined") {
			b.type = "row"
		}
		if ("row" === b.type) {
			if (typeof b.uc !== "object") {
				return false
			}
			return this.__cleanCache(b.q, b.uc)
		}
		if ("page" === b.type) {
			return this.__cleanCacheByPage(b.q)
		}
		return true
	};
	this.__cleanCache = function(e, d) {
		var b = this.initCacheCtrl(e, d);
		if (false === b) {
			return false
		}
		if (false === b.keyExists()) {
			return false
		}
		var c = b.cleanCache();
		return c
	};
	this.__cleanCacheByPage = function(d) {
		var b = new Cache();
		b.setKey(d);
		var c = b.cleanCacheByKey();
		return c
	};
	this.getData = function(e) {
		if (typeof e !== "object" || typeof e.uc !== "object") {
			return false
		}
		var f = e.uc.getParamData();
		if (false === f) {
			return false
		}
		var d = new UrlImplode();
		d.setImplode(f);
		var g = d.getUrlsData();
		var h = {};
		for (p in g) {
			h[p] = this.initCacheCtrl(p, g[p])
		}
		var b = {
			_login : 1
		};
		for (cacheKey in g) {
			if (true === h[cacheKey].keyExists()) {
				var c = h[cacheKey].readCache();
				if (false !== c && "" !== c.body) {
					b[cacheKey] = c.body;
					d.delUrlControl(cacheKey)
				}
			}
		}
		if (0 < getCount(d.getUrlsData())) {
			e.uc.addReplaceParamData(d.getImplode());
			return this.getServerData(e, b)
		}
		if (e.success !== undefined) {
			e.success(b)
		}
		return true
	};
	this.getServerData = function(c, e) {
		gMessage.showMessageTop();
		if (typeof c !== "object" || typeof c.uc !== "object") {
			return false
		}
		var d = c.uc.getParamData();
		if (false === d) {
			return false
		}
		var b = new UrlImplode();
		b.setImplode(d);
		var h = b.getUrlsData();
		var i = {};
		for (p in h) {
			i[p] = this.initCacheCtrl(p, h[p])
		}
		c.url = c.uc.getUrl();
		var f = false;
		if (typeof c.success !== "undefined") {
			f = c.success
		}
		c.success = function(j) {
			for (p in i) {
				if (i[p].keyExists()) {
					i[p].writeCache(j[p])
				}
			}
			for (q in e) {
				if ("_login" !== q) {
					j[q] = e[q]
				}
			}
			if (typeof f === "function") {
				f(j)
			}
		};
		var g = $.ajax(c);
		if (typeof c.async !== "undefined" && c.async === false) {
			return g.responseText
		}
	}
}
var gCc = new CacheControl();